package com.abbcc.module.admin;

import org.springframework.beans.factory.annotation.Autowired;

import com.abbcc.action.BaseAction;
import com.abbcc.models.TdMenu;
import com.abbcc.service.MenuService;

public class MenuAction extends BaseAction<TdMenu>{
	private int userId;
	public String[] menus;
	@Autowired
	MenuService menuService;
	public String view(){
		return VIEW;
	}
	public String update(){
		if(menus==null)
			return VIEW;
		String hql = "delete TdMenu where userId=?";
		menuService.bulkUpdate(hql, entity.getUserId());
		for(String m:menus){
			TdMenu tm = new TdMenu();
			tm.setUserId(entity.getUserId());
			tm.setName(m);
			menuService.save(tm);
		}
		result = "修改成功!";
		return VIEW;
	}
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	
}
